<!-- #layout name=blank-->
<div class="page-header">
    <h1 class="title">Product categories</h1>
</div>
<div data-bind="component: { name: 'kb-breadcrumb', params:[{
    name: 'SITES'
},{
    name: 'DASHBOARD'
},{
    name: Kooboo.text.common.ProductCategories
}]}"></div>

<div class="panel panel-default panel-small">
    <div class="panel-heading">
        <a href="javascript:;" class="btn navbar-btn green" data-bind="click: onAddNewCategory">Add new category</a>
        <a href="javascript:;" class="btn navbar-btn green" data-bind="visible: showFunctionBtn, click: onAddNewSubCategory">Add sub-category</a>
        <a href="javascript:;" class="btn navbar-btn green" data-bind="visible: showFunctionBtn, click: onEdit">Edit</a>
        <a href="javascript:;" class="btn navbar-btn red" data-bind="visible: showFunctionBtn, click: removeCategory">Delete</a>
    </div>
    <div class="panel-body">
        <div id="categories"></div>
    </div>
</div>
<button class="btn green" data-bind="visible: isJsTreeChanged, click: saveCategory">Save</button>

<div data-bind="modal: showMultilingualModal" class="modal fade" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-bind="click: onHideMultilingualModal"><i class="fa fa-close"></i></button>
                <h4 class="modal-title">Multilingual</h4>
            </div>
            <div class="modal-body" data-bind="if: currentCateNames()">
                <!-- ko foreach: cultureKeys -->
                <div class="form-group">
                    <label class="control-label" data-bind="text: $data + ' - ' + $parent.cultures()[$data]"></label>
                    <input type="text" class="form-control" data-bind="value: $parent.currentCateNames()[$data]">
                </div>
                <!-- /ko -->
            </div>
            <div class="modal-footer">
                <button class="btn green" data-bind="click: onSaveMultilingualModal">Save</button>
                <button class="btn grey" data-bind="click: onHideMultilingualModal">Cancel</button>
            </div>
        </div>
    </div>
</div>

<script type="text/html" type="text/html" id="category-template">
    <li data-bind="attr: { 'data-id': id }">
        <span data-bind="text: name"></span>
        <ul data-bind="template: { name: 'category-template', foreach: subCates}"></ul>
    </li>
</script>
<script>
    (function() {
        Kooboo.loadJS([
            "/_Admin/Scripts/kooboo/Guid.js",
            "/_Admin/Scripts/lib/jstree.min.js",
            "/_Admin/Scripts/components/kbBreadcrumb.js",
        ]);
        Kooboo.loadCSS([
            "/_Admin/Styles/jstree/style.min.css"
        ])
    })()
</script>
<script src="/_Admin/View/ECommerce/Product/Categories.js"></script>